package com.dct.android.action;

import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dct.android.dao.MemberDAO;
import com.dct.android.dao.MemberDTO;

public class MemberSearchAction implements Action {

	@Override
	public void execute(HttpServletRequest req, HttpServletResponse res)
	throws IOException, ServletException {
		String phone = req.getParameter("phone");
		String email = req.getParameter("email");
		
		MemberDAO dao = new MemberDAO();
		MemberDTO dto = new MemberDTO();
		if(phone!=null){
			dto = dao.memPhoneSearch(phone);
		} else if(email!=null){
			dto = dao.memEmailSearch(email);
		}
		
		res.setContentType("text/xml; charset=utf-8");
		PrintWriter out = res.getWriter();
		out.println("<?xml version='1.0' encoding='utf-8'?>");
		out.println("<result>");
		out.println("	<idx>"+dto.getIdx()+"</idx>");
		out.println("	<email>"+dto.getEmail()+"</email>");
		out.println("	<pwd>"+dto.getPwd()+"</pwd>");
		out.println("	<name>"+dto.getName()+"</name>");
		out.println("	<phone>"+dto.getPhone()+"</phone>");
		out.println("	<nlang>"+dto.getNlang()+"</nlang>");
		out.println("	<slang>"+dto.getSlang()+"</slang>");
		out.println("	<level>"+dto.getLevel()+"</level>");
		out.println("	<jdate>"+dto.getJdate()+"</jdate>");
		out.println("</result>");
	}

}
